// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 添加新闻 */
export async function createSysDept(options) {
  return request<{
    data;
  }>('/api/sysDept/add', {
    method: 'POST',
    data: options || {},
  });
}

export async function updateSysDept(options) {
  return request<{
    data;
  }>('/api/sysDept/update', {
    method: 'POST',
    data: options || {},
  });
}

/** 删除新闻 */
export async function deleteSysDept(options) {
  return request<{
    data;
  }>('/api/sysDept/delete', {
    method: 'GET',
    params: { id: options },
  });
}

/** 首页产品详情 */
export async function fetchSysDept(options) {
  console.log(options, '-');
  const result = await request('/api/sysDept/queryDeptTree', {
    method: 'GET',
    data: options,
  });
  console.log(result, '-');
  return { data: result.data, success: true };
}

export async function updateDeptStatus(options) {
  return request<{
    data;
  }>('/api/sysDept/updateDeptStatus', {
    method: 'POST',
    data: options || {},
  });
}

export async function queryDeptTree(options) {
  return request<{
    data;
  }>('/api/sysDept/queryDeptTree', {
    method: 'GET',
    data: options || {},
  });
}

export async function createMenu(options) {
  return request<{
    data;
  }>('/api/sysMenu/add', {
    method: 'POST',
    data: options || {},
  });
}

/** 删除菜单 */
export async function deleteMenu(options) {
  return request<{
    data;
  }>('/api/sysMenu/delete', {
    method: 'GET',
    params: { id: options },
  });
}

/** 菜单列表 */
export async function fetchMenus(options) {
  // console.log(options, '-');queryAllMenuTree
  const result = await request('/api/sysMenu/queryAllMenuTree', {
    method: 'POST',
    data: options,
  });
  console.log(result, '-');
  return { data: result.data, success: true, total: result.total };
}

export async function fetchRoleMenus(options) {
  console.log(options, '-');
  const result = await request('/api/sysMenu/queryList', {
    method: 'GET',
    data: options,
  });
  return result;
}

export async function queryAllMenuTree() {
  const result = await request('/api/sysMenu/queryAllMenuTree', {
    method: 'POST',
    data: {},
  });
  console.log(result, '-');
  return result;
}

export async function updateMenu(options) {
  return request<{
    data;
  }>('/api/sysMenu/update', {
    method: 'POST',
    data: options || {},
  });
}

export async function createRole(options) {
  console.log(options, 'value');
  return request<{
    data;
  }>('/api/sysRole/add', {
    method: 'POST',
    data: options || {},
  });
}

/** 删除新闻 */
export async function deleteRole(options) {
  return request<{
    data;
  }>('/api/sysRole/delete', {
    method: 'GET',
    params: options,
  });
}

/** 首页产品详情 */
export async function fetchRoleList(options) {
  console.log(options, '-');
  const result = await request('/api/sysRole/queryPage', {
    method: 'POST',
    data: options,
  });
  console.log(result, '-');
  return { data: result.data.records, success: true };
}

export async function updateRole(options) {
  return request<{
    data;
  }>('/api/sysRole/update', {
    method: 'POST',
    data: options || {},
  });
}

export async function roleSelectBox() {
  const result = await request<{
    data;
  }>('/api/sysRole/roleSelectBox', {
    method: 'GET',
  });
  return result;
}

export async function queryRoleAuth(options) {
  console.log(options, '-');
  const result = await request('/api/sysRole/queryRoleAuth', {
    method: 'GET',
    params: options,
  });
  return result;
}

export const getDictionaryList = async (params) => {
  const response = await request('/api/dataDictionary/queryListIndex', { params });
  return { data: response.data, success: true, total: response.total };
};

export const getDictionaryDetails = async (code) => {
  const response = await request(`/api/dataDictionary/queryListById`, {
    method: 'GET',
    params: { id: code },
  });
  return response.data;
};

export const updateDictionaryDetails = async (code, details) => {
  const response = await request(`/api/dictionary/${code}`, { method: 'PUT', data: details });
  return response.data;
};

export const createDictionaryDetails = async (details) => {
  const response = await request('/api/dataDictionary/addDataDictionaryB', {
    method: 'POST',
    data: details,
  });
  return response.data;
};
export const updateDataDictionaryB = async (details) => {
  const response = await request('/api/dataDictionary/updateDataDictionaryB', {
    method: 'POST',
    data: details,
  });
  return response.data;
};


export const createDictionaryDetailsA = async (details) => {
  const response = await request('/api/dataDictionary/addDataDictionaryA', {
    method: 'POST',
    data: details,
  });
  return response.data;
};

export const deleteDictionaryDetails = async (code) => {
  const response = await request(`/api/dataDictionary/delDataDictionaryB`, {
    method: 'GET',
    params: { id: code },
  });
  return response.data;
};
